<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<html>
<head>
    <title>供货商管理</title>
</head>
<body>
<input type="hidden" id="supplier" value="${supplier}"/>
<div ng-app="myApp" ng-controller="SupplierCtrl">
    <ui-form key="supplierUpdate" column="2">
        <input name="id" type="hidden" value="${supplier.id}"/>
        <ui-form-input name="code" label="供应商编码:" value="${supplier.code}"></ui-form-input>
        <ui-form-input name="name" label="供应商名称:"  value="${supplier.name}"></ui-form-input>
        <ui-form-select-remote label="供货商分组" url="system/supplier/listgroups" value-name="id" text-name="name" name="groupId" value="${supplier.groupId}"></ui-form-select-remote>
        <ui-form-select name="state" label="激活状态:" value="${supplier.state}">
            <option value="0">否</option>
            <option value="1">是</option>
        </ui-form-select>
        <ui-form-select name="isCombined" label="是否组包:" value="${supplier.isCombined}">
            <option value="0">否</option>
            <option value="1">是</option>
        </ui-form-select>
    </ui-form>
</div>
<script>
    angular.module('myApp', ['ui.form']);
    angular.module('myApp').controller('SupplierCtrl', function ($scope) {
//        $.ajax({
//            url:"system/supplier/getbyid",
//            type:"post",
//            success:function (result) {
//                $scope.data=result.data;
//                 $scope.$apply();
//            },
//            fail:function (result) {
//
//            }
//        });
        $scope.$on('ui.form.submit',function (event,param) {
            $.ajax({
                url:"system/supplier/update",
                type:"post",
                data:param
            }).done(function (result) {
                if(result.code=='0000'){
                    toastr.success(result.data);
                }else{
                    toastr.error(result.msg);
                }
            }).fail(function (err) {

            });
        })
    });
</script>
</body>
</html>